package com.atguigu.gmall.order.service;

import com.atguigu.gmall.model.cart.CartInfo;
import com.atguigu.gmall.model.enums.ProcessStatus;
import com.atguigu.gmall.model.order.OrderInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;
import java.util.Map;

public interface OrderService extends IService<OrderInfo> {
    Long saveOrderInfo(OrderInfo orderInfo);

    /**
     * 生成流水号
     * @param userId
     * @return
     */
    String getTradeCode(String userId);

    /**
     * 检验流水号
     * @param userId
     * @param tradeCode
     * @return
     */
    Boolean checkTradeCode(String userId, String tradeCode);

    /**
     * 删除流水号
     * @param userId
     */
    void deleteTradeCode(String userId);

    /**
     * 验证库存
     * @param skuId
     * @param skuNum
     * @return
     */
    boolean checkStock(Long skuId, Integer skuNum);

    IPage<OrderInfo> getOrder(Page<OrderInfo> cartInfoPage, String userId, String orderStatus);

    /**
     * 取消订单
     * @param orderId
     */
    void execExpiredOrder(Long orderId);

    OrderInfo getOrderInfo(Long orderId);

    void updateOrder(Long orderId, ProcessStatus processStatus);

    void sendDeductStockMsg(Long orderId);

    public Map<String, Object> initWareOrder(OrderInfo orderInfo);

    List<OrderInfo> spilt(String orderId, String wareSkuMap);

    void execExpiredOrder(Long orderId, String flag);
}
